package com.llmcu.source.javase.objectoriented.internalclass;

import lombok.Data;

/**
 * 外部类
 *
 * @author liuling
 * @date 2024/10/5 16:37
 */
@Data
public class Outer2 {
    private String name;
    static private int age;

    public static void main(String[] args) {
        /**
         * 局部内部类
         */
        @Data
        class MethodInner{
            private String name;
            // 内部类不支持静态声明
            // static private int age;
        }

    }

    /**
     * 成员内部类
     */
    @Data
    class ClassInner{
        private String name;
        // 内部类不支持静态声明
        // static private int age;
        public void foo (){
            String name = Outer2.this.name;
            String name1 = this.name;
            int age = Outer2.age;
        }
    }
    /**
     *  静态成员内部类
     */
    @Data
    static class StaticClassInner{
        private String name;
        static private int age;
        public void foo (){
            // 静态内部类中不能使用Outer.this
//            String name1 = Outer.this.name;
            String name = this.name;
            int age = Outer2.age;
            int age1 = StaticClassInner.age;
        }
    }
}
